package Example;
//求s=a+aa+aaa+aaaa+aa...a的值，其中a是一个数字。
//例如2+22+222+2222+22222(此时共有5个数相加)，几个数相加有键盘控制。

import java.util.Scanner;

public class Demo8 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("你希望有几个几相加：");
        int number = scan.nextInt();
        int a = scan.nextInt();
        int sum = 0;
        int addition = 0;
        for (int i = 0; i < number; i++) {
            addition += (int)(a* Math.pow(10,i));
            sum += addition;
        }
        System.out.println(number + "个数相加的和为：" + sum);
    }
}
